<?php
class JYVisit {
	const table = 'VISIT';
	const pk = 'V_ID';

	public function getVisitTimes($bizCode) {
		$field = "MAX(VISIT_TIMES) AS MAX_TIMES";
		$where = "BIZ_CODE='{$bizCode}' AND UNIT_ID=".CSM_UNIT_ID;
		$rs = JYDB::find('VISIT', $where, $field);
		if ($rs) {
			return $rs['MAX_TIMES'];
		} else {
			return 0;
		}
	}
	
	/**
	 * 获取今日总访问人数
	 * @param unknown_type $uid
	 */
	public function getTodayVisit($uid) {
		$startTime = date('Y-m-d');
		$rs = JYDB::find(self::table, "USER_ID={$uid} AND VISIT_TIME>='{$startTime}'", "COUNT(1) AS ACC");
		return $rs ? $rs['ACC'] : 0;
	}
	
	/**
	 * 获取本月总访问人数
	 * @param unknown_type $uid
	 */
	public function getMonthVisit($uid) {
		$startTime = date('Y-m-01');
		$rs = JYDB::find(self::table, "USER_ID={$uid} AND VISIT_TIME>='{$startTime}'", "COUNT(1) AS ACC");
		return $rs ? $rs['ACC'] : 0;
	}

}